let fs = require("fs");
let readFun = (url)=>{
    return new Promise((reslove,reject)=>{
        fs.readFile(url,'utf-8',(err,data)=>{
            if(err){
                reject("读取失败")
            }else{
                data = JSON.parse(data)
                reslove(data)
            }
        })
    })
}

let writeFun = (url,data)=>{
    return new Promise((reslove,reject)=>{
        fs.writeFile(url,data,(err)=>{
            if(err){
                reject("写入失败")
            }else{
                reslove("写入成功")
            }
        })
    })
}

module.exports = {
    readFun,
    writeFun
}